package org.ycx.upms.dao.auto;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
import org.ycx.upms.dao.model.SecGroup;
import org.ycx.upms.dao.model.SecGroupExample;

import java.util.List;

public interface SecGroupMapper {
    @SelectProvider(type=SecGroupSqlProvider.class, method="countByExample")
    long countByExample(SecGroupExample example);

    @DeleteProvider(type=SecGroupSqlProvider.class, method="deleteByExample")
    int deleteByExample(SecGroupExample example);

    @Delete({
        "delete from sec_group",
        "where GID = #{gid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer gid);

    @Insert({
        "insert into sec_group (GROUP_NAME, G_DESC, ",
        "G_COUNT)",
        "values (#{groupName,jdbcType=VARCHAR}, #{gDesc,jdbcType=VARCHAR}, ",
        "#{gCount,jdbcType=INTEGER})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="gid", before=false, resultType=Integer.class)
    int insert(SecGroup record);

    @InsertProvider(type=SecGroupSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="gid", before=false, resultType=Integer.class)
    int insertSelective(SecGroup record);

    @SelectProvider(type=SecGroupSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="GID", property="gid", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="GROUP_NAME", property="groupName", jdbcType=JdbcType.VARCHAR),
        @Result(column="G_DESC", property="gDesc", jdbcType=JdbcType.VARCHAR),
        @Result(column="G_COUNT", property="gCount", jdbcType=JdbcType.INTEGER)
    })
    List<SecGroup> selectByExample(SecGroupExample example);

    @Select({
        "select",
        "GID, GROUP_NAME, G_DESC, G_COUNT",
        "from sec_group",
        "where GID = #{gid,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="GID", property="gid", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="GROUP_NAME", property="groupName", jdbcType=JdbcType.VARCHAR),
        @Result(column="G_DESC", property="gDesc", jdbcType=JdbcType.VARCHAR),
        @Result(column="G_COUNT", property="gCount", jdbcType=JdbcType.INTEGER)
    })
    SecGroup selectByPrimaryKey(Integer gid);

    @UpdateProvider(type=SecGroupSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") SecGroup record, @Param("example") SecGroupExample example);

    @UpdateProvider(type=SecGroupSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") SecGroup record, @Param("example") SecGroupExample example);

    @UpdateProvider(type=SecGroupSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(SecGroup record);

    @Update({
        "update sec_group",
        "set GROUP_NAME = #{groupName,jdbcType=VARCHAR},",
          "G_DESC = #{gDesc,jdbcType=VARCHAR},",
          "G_COUNT = #{gCount,jdbcType=INTEGER}",
        "where GID = #{gid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(SecGroup record);
}